<!DOCTYPE html>
<html>
<title>cordova test</title>
<script>
  function onTestBtnClick() {
    alert('测试Cordova')
    document.addEventListener('deviceready', () => {
     var exec = window.Cordova.exec
     exec((result) => {
        alert(JSON.stringify(result))
      }, () => {
        alert('fail')
      }, 'HelloBridge', 'say', [{name:'cordova'}])
    })
  }
  function onTestAliasBtnClick() {
    alert('测试Cordova别名')
    document.addEventListener('deviceready', () => {
     var exec = window.Cordova.exec
     exec((result) => {
        alert(JSON.stringify(result))
      }, () => {
        alert('fail')
      }, 'TestBridge', 'print', [{name:'alias'}])
    })
  }
  function onTestInterceptBack() {
    document.addEventListener('deviceready', () => {
      alert('开始监听back按钮点击事件')
      document.addEventListener('backbutton', () => {
        alert('收到back按钮点击事件')
      })
    })
  }
</script>
<body>
    <button id="buttonA" type="button" onclick="onTestBtnClick()" style="font-size:40px; width:200px; height:60px">测试</button>
    <div style="width: 200px; height: 12px"></div>
    <button id="buttonB" type="button" onclick="onTestAliasBtnClick()" style="font-size:40px; width:200px; height:60px">测试别名</button>
    <div style="width: 200px; height: 12px"></div>
    <button id="buttonC" type="button" onclick="onTestInterceptBack()" style="font-size:28px; width:200px; height:60px">H5拦截Back事件</button>
</body>
 <script type="text/javascript" charset="utf-8" src="https://www.baidu.com/js/cordova.harmony.js" ></script>
</html>
